package com.kay.server;

/**
 * @Description: 封装Http响应信息，请求头信息
 * @Author: Kay
 * @CreateDate: 2021/8/3$ 9:59$
 * @UpdateUser: Kay
 * @UpdateDate: 2021/8/3$ 9:59$
 */
public class HttpProtocolUtils {

    /**
     * 返回200请求头
     *
     * @param contentLength
     * @return
     */
    public static String getHeader200(long contentLength) {
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + contentLength + " \n" +
                "\r\n";
    }

    /**
     * 404
     * @return
     */
    public static String getContent404() {
        String content = "404 Page Not Found ~ ";
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + content.getBytes().length + " \n" +
                "\r\n" + content;
    }
}
